#ifndef _PLY_H_
#define _PLY_H_
 
#include <GL/gl.h>
#include <GL/glu.h>

#include <string>
#include <fstream>
#include <iostream>

#include <Stage-4.1/stage.hh>

/*
 * for .ply files with format:
 *
		ply
		format ascii 1.0
		comment VCGLIB generated
		element vertex NUM_VERTICES
		property float x
		property float y
		property float z
		property float nx
		property float ny
		property float nz
		property uchar red
		property uchar green
		property uchar blue
		property uchar alpha
		element face NUM_FACES
		property list uchar int vertex_indices
		end_header
*/
 
 
class ModelPLY : public Stg::Model
{
public:

	float scale;

	/* constructors and destructor */
	ModelPLY(Stg::World *world, Stg::Pose pose, std::string fname);
	ModelPLY(Stg::Pose pose, std::string fname);
	virtual ~ModelPLY();

	/* load model from a file */
	void load_file(std::string fname);

	/* render model with current camera transformation */
	virtual void DrawBlocks();

	void setScale(float _scale) { scale = _scale; }
	float getScale() { return scale; }

private:

    GLuint *faces_tri;
	GLfloat *vertex_buf;
	GLfloat *normal_buf;
	GLubyte *colour_buf;

	unsigned num_verts;
	unsigned num_faces;

};

#endif
